package ExerciseOne;

import java.util.Objects;

public class EqualsTest {

	public static void main(String[] args) {
//		String name1 = "石文学";
//		String name2 = "普元庆";
//		String name3 = "石文学";
//		System.out.println(name1 == name2);
//		System.out.println(name1.equals(name2));
//		System.out.println(name1.equals(name3));

		Order order1 = new Order("石文学",18);
		Order order2 = new Order("普元庆",18);
		Order order3 = new Order("石文学",18);
		System.out.println(order1.equals(order2));
		System.out.println(order1.equals(order3));
		
	}

}

class Order
{
	String name;
	int age;
	
	public Order()
	{
		
	}
	
	public Order(String name,int age)
	{
		this.name = name;
		this.age = age;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Order other = (Order) obj;
		return age == other.age && Objects.equals(name, other.name);
	}
	
}